

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>11.12. dumbdbm — Portable DBM implementation &mdash; Python v2.7.8 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.7.8',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.7.8 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v2.7.8 documentation" href="../index.html" />
    <link rel="up" title="11. Data Persistence" href="persistence.html" />
    <link rel="next" title="11.13. sqlite3 — DB-API 2.0 interface for SQLite databases" href="sqlite3.html" />
    <link rel="prev" title="11.11. bsddb — Interface to Berkeley DB library" href="bsddb.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
 
    

  </head>
  <body>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="sqlite3.html" title="11.13. sqlite3 — DB-API 2.0 interface for SQLite databases"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="bsddb.html" title="11.11. bsddb — Interface to Berkeley DB library"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="http://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">Python v2.7.8 documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="persistence.html" accesskey="U">11. Data Persistence</a> &raquo;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-dumbdbm">
<span id="dumbdbm-portable-dbm-implementation"></span><h1>11.12. <a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-mod docutils literal"><span class="pre">dumbdbm</span></tt></a> &#8212; Portable DBM implementation<a class="headerlink" href="#module-dumbdbm" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-mod docutils literal"><span class="pre">dumbdbm</span></tt></a> module has been renamed to <tt class="xref py py-mod docutils literal"><span class="pre">dbm.dumb</span></tt> in Python 3.
The <a class="reference internal" href="../glossary.html#term-to3"><em class="xref std std-term">2to3</em></a> tool will automatically adapt imports when converting your
sources to Python 3.</p>
</div>
<div class="admonition note" id="index-0">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-mod docutils literal"><span class="pre">dumbdbm</span></tt></a> module is intended as a last resort fallback for the
<a class="reference internal" href="anydbm.html#module-anydbm" title="anydbm: Generic interface to DBM-style database modules."><tt class="xref py py-mod docutils literal"><span class="pre">anydbm</span></tt></a> module when no more robust module is available. The <a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-mod docutils literal"><span class="pre">dumbdbm</span></tt></a>
module is not written for speed and is not nearly as heavily used as the other
database modules.</p>
</div>
<p>The <a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-mod docutils literal"><span class="pre">dumbdbm</span></tt></a> module provides a persistent dictionary-like interface which
is written entirely in Python.  Unlike other modules such as <a class="reference internal" href="gdbm.html#module-gdbm" title="gdbm: GNU's reinterpretation of dbm. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">gdbm</span></tt></a> and
<a class="reference internal" href="bsddb.html#module-bsddb" title="bsddb: Interface to Berkeley DB database library"><tt class="xref py py-mod docutils literal"><span class="pre">bsddb</span></tt></a>, no external library is required.  As with other persistent
mappings, the keys and values must always be strings.</p>
<p>The module defines the following:</p>
<dl class="exception">
<dt id="dumbdbm.error">
<em class="property">exception </em><tt class="descclassname">dumbdbm.</tt><tt class="descname">error</tt><a class="headerlink" href="#dumbdbm.error" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised on dumbdbm-specific errors, such as I/O errors.  <a class="reference internal" href="exceptions.html#exceptions.KeyError" title="exceptions.KeyError"><tt class="xref py py-exc docutils literal"><span class="pre">KeyError</span></tt></a> is
raised for general mapping errors like specifying an incorrect key.</p>
</dd></dl>

<dl class="function">
<dt id="dumbdbm.open">
<tt class="descclassname">dumbdbm.</tt><tt class="descname">open</tt><big>(</big><em>filename</em><span class="optional">[</span>, <em>flag</em><span class="optional">[</span>, <em>mode</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#dumbdbm.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Open a dumbdbm database and return a dumbdbm object.  The <em>filename</em> argument is
the basename of the database file (without any specific extensions).  When a
dumbdbm database is created, files with <tt class="file docutils literal"><span class="pre">.dat</span></tt> and <tt class="file docutils literal"><span class="pre">.dir</span></tt> extensions
are created.</p>
<p>The optional <em>flag</em> argument is currently ignored; the database is always opened
for update, and will be created if it does not exist.</p>
<p>The optional <em>mode</em> argument is the Unix mode of the file, used only when the
database has to be created.  It defaults to octal <tt class="docutils literal"><span class="pre">0666</span></tt> (and will be modified
by the prevailing umask).</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.2: </span>The <em>mode</em> argument was ignored in earlier versions.</p>
</dd></dl>

<p>In addition to the dictionary-like methods, <tt class="docutils literal"><span class="pre">dumbdm</span></tt> objects
provide the following method:</p>
<dl class="function">
<dt id="dumbdbm.close">
<tt class="descclassname">dumbdbm.</tt><tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#dumbdbm.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the <tt class="docutils literal"><span class="pre">dumbdm</span></tt> database.</p>
</dd></dl>

<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt>Module <a class="reference internal" href="anydbm.html#module-anydbm" title="anydbm: Generic interface to DBM-style database modules."><tt class="xref py py-mod docutils literal"><span class="pre">anydbm</span></tt></a></dt>
<dd>Generic interface to <tt class="docutils literal"><span class="pre">dbm</span></tt>-style databases.</dd>
<dt>Module <a class="reference internal" href="dbm.html#module-dbm" title="dbm: The standard &quot;database&quot; interface, based on ndbm. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">dbm</span></tt></a></dt>
<dd>Similar interface to the DBM/NDBM library.</dd>
<dt>Module <a class="reference internal" href="gdbm.html#module-gdbm" title="gdbm: GNU's reinterpretation of dbm. (Unix)"><tt class="xref py py-mod docutils literal"><span class="pre">gdbm</span></tt></a></dt>
<dd>Similar interface to the GNU GDBM library.</dd>
<dt>Module <a class="reference internal" href="shelve.html#module-shelve" title="shelve: Python object persistence."><tt class="xref py py-mod docutils literal"><span class="pre">shelve</span></tt></a></dt>
<dd>Persistence module which stores non-string data.</dd>
<dt>Module <a class="reference internal" href="whichdb.html#module-whichdb" title="whichdb: Guess which DBM-style module created a given database."><tt class="xref py py-mod docutils literal"><span class="pre">whichdb</span></tt></a></dt>
<dd>Utility module used to determine the type of an existing database.</dd>
</dl>
</div>
<div class="section" id="dumbdbm-objects">
<span id="id1"></span><h2>11.12.1. Dumbdbm Objects<a class="headerlink" href="#dumbdbm-objects" title="Permalink to this headline">¶</a></h2>
<p>In addition to the methods provided by the <a class="reference internal" href="userdict.html#UserDict.DictMixin" title="UserDict.DictMixin"><tt class="xref py py-class docutils literal"><span class="pre">UserDict.DictMixin</span></tt></a> class,
<a class="reference internal" href="#module-dumbdbm" title="dumbdbm: Portable implementation of the simple DBM interface."><tt class="xref py py-class docutils literal"><span class="pre">dumbdbm</span></tt></a> objects provide the following methods.</p>
<dl class="method">
<dt id="dumbdbm.dumbdbm.sync">
<tt class="descclassname">dumbdbm.</tt><tt class="descname">sync</tt><big>(</big><big>)</big><a class="headerlink" href="#dumbdbm.dumbdbm.sync" title="Permalink to this definition">¶</a></dt>
<dd><p>Synchronize the on-disk directory and data files.  This method is called by the
<a class="reference internal" href="#dumbdbm.dumbdbm.sync" title="dumbdbm.dumbdbm.sync"><tt class="xref py py-meth docutils literal"><span class="pre">sync()</span></tt></a> method of <tt class="xref py py-class docutils literal"><span class="pre">Shelve</span></tt> objects.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">11.12. <tt class="docutils literal"><span class="pre">dumbdbm</span></tt> &#8212; Portable DBM implementation</a><ul>
<li><a class="reference internal" href="#dumbdbm-objects">11.12.1. Dumbdbm Objects</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="bsddb.html"
                        title="previous chapter">11.11. <tt class="docutils literal docutils literal docutils literal"><span class="pre">bsddb</span></tt> &#8212; Interface to Berkeley DB library</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="sqlite3.html"
                        title="next chapter">11.13. <tt class="docutils literal docutils literal"><span class="pre">sqlite3</span></tt> &#8212; DB-API 2.0 interface for SQLite databases</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/dumbdbm.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="sqlite3.html" title="11.13. sqlite3 — DB-API 2.0 interface for SQLite databases"
             >next</a> |</li>
        <li class="right" >
          <a href="bsddb.html" title="11.11. bsddb — Interface to Berkeley DB library"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="http://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">Python v2.7.8 documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="persistence.html" >11. Data Persistence</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2014, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="http://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Jun 29, 2014.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>

  </body>
</html>